package com.zwf.controller;

import cn.hutool.core.util.StrUtil;
import com.zwf.FileSearchTool;
import com.zwf.bo.SearchBO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/zwf/demo")
public class SearchController {

    @Resource
    private FileSearchTool fileSearchTool;

    /**
     * 检索关键字(文件)
     * @param key
     * @return
     * @throws Exception
     */
    @PostMapping("/searchFileWithDetails")
    private List<SearchBO> searchFileWithDetails(String key) throws Exception {
        if (StrUtil.isEmpty(key)) {
            return null;
        }
        List<SearchBO> boList = fileSearchTool.searchFilesWithDetails(key);
        return boList;
    }

}
